Dynomotion

Group: DynoMotion Message: 10459 From: cnc_machines Date: 11/2/2014
Subject: M-Code Hold Bit
I have a question about using a custom M-Code for a CNC program. I set up M100 to be a wait bit for a particular IO on my KStep board. When I run the CNC program the program doesn't hold immediately at the M100 code. Rather it continues running for a few seconds before it stops and requires the IO input to continue running again.

I found that if I change the look ahead value in the trajectory planner it will reduce the number of lines of G-Code that are processed before it stops. (Seems like if I put 3 seconds in it takes about that long to stop). Is there any way to get the program to stop immediately once it arrives at the wait bit M-Code?

Thanks,

Scott



Group: DynoMotion Message: 10460 From: Tom Kerekes Date: 11/2/2014
Subject: Re: M-Code Hold Bit
Hi Scott,

What Version are you using?  What exactly are you needing the wait for?

Regards
TK


Group: DynoMotion Message: 10461 From: cnc_machines Date: 11/2/2014
Subject: Re: M-Code Hold Bit
Tom,

I am using KMotion 432. I have a sensors on a work holding clamps on my CNC machine which change position as the cutter moves around the work piece. When the clamps switch positions they send a confirmation bit that they have reached full hydraulic pressure. This way I know it is okay to continue cutting.

I would like to use the M-Codes to trigger clamps closing, and M-Codes to stop the program to confirm that the action took place. Do you have any ideas on how this would function?

I am also intrigued with the options on the drop down menu "Execute PC" and "PC App Callback". Could you help me understand what these were originally designed to do?

Thanks,

Scott
Group: DynoMotion Message: 10462 From: Tom Kerekes Date: 11/2/2014
Subject: Re: M-Code Hold Bit
Hi Scott,

The Embedded Motion Wait is probably not something you need.  It is designed to embed a real-time wait of something that may be very short in time (ie 1 millisecond) within a motion sequence and to guarantee the motion continue within 90us of when the I/O changes.  To do that the GCode Interpreter must have Trajectory Planned ahead (seconds) so that any Windows stalls would not cause problems.  The GCode Interpreter and the Trajectory Planner always work far ahead in time from where the Machine Tool actually is.  So I think you would find that the wait occurs at the right place in the motion sequence even though the KMotionCNC Screen shows a GCode line further along.  After Version 4.32 the Test Versions have a mechanism to maintain a Real-Time State that more closely matches the actual Machine Tool Position.  That is now used to display status (GCode Line Number, Offsets used, etc) so what is displayed is more indicative of the current machine state. 

However in your case it doesn't sound like timing is super critical.  If you define an M Code as a C Program that waits for a bit, things will be more logical.  The M Code will then cause the Trajectory Planner to plan a complete stop, flush all buffered motion, wait for all motion to complete, download/execute the C Program, wait for the C program to finish, then refill the motion buffer, and begin executing more motion.  All this will will normally happen in a few milliseconds but on very rare occasions it may be a second or so before motion continues in the event Windows is stalled doing something critical just when it is time for the motion to continue.   A Program to wait for a bit to be High before terminating could be:

#include "KMotionDef.h"

void main()
{
    while (!ReadBit(46)) ;
}

The Exec/Wait Action should be selected in order for the C Program to be executed and for the Interpreter to wait for the C Program to terminate before continuing.  If you have an Init program that executes in Thread #1 then choose an unused thread for this MCode so it can run in parallel (ie Thred #2).


The "Execute PC" Action Executes a Program on the PC of your choosing.  It might be some .exe or .bat file.

The "PC App Callback" is an advanced feature.  It provides a hook to call custom code that you add to the Host Application yourself.  One user used it somehow to call an IronPython script.

HTH
Regards
TK




From: "cnc_machines@... [DynoMotion]" <DynoMotion@yahoogroups.com>
To: DynoMotion@yahoogroups.com
Sent: Sunday, November 2, 2014 9:06 PM
Subject: Re: [DynoMotion] M-Code Hold Bit

 
Tom,

I am using KMotion 432. I have a sensors on a work holding clamps on my CNC machine which change position as the cutter moves around the work piece. When the clamps switch positions they send a confirmation bit that they have reached full hydraulic pressure. This way I know it is okay to continue cutting.

I would like to use the M-Codes to trigger clamps closing, and M-Codes to stop the program to confirm that the action took place. Do you have any ideas on how this would function?

I am also intrigued with the options on the drop down menu "Execute PC" and "PC App Callback". Could you help me understand what these were originally designed to do?

Thanks,

Scott


Group: DynoMotion Message: 10467 From: cnc_machines Date: 11/3/2014
Subject: Re: M-Code Hold Bit
Tom,

Excellent! Thanks for the explanation. It seems to be working well. If I use this method will I need to use a thread for each wait M-Code?

Looks like the way I would do this is to make an M-Code that would set an IO bit to close a particular clamp. And then immediately afterwards in the G-Code to make another M-Code that will wait for the pressure switch IO to close indicating that the clamp has closed. Perhaps I could do both in one C Program?

Is there a location in the documentation to read about the fault output? I am thinking that it would be nice to set a timer and fault out if the clamp doesnt close in a certain amount of time. It would be great if I could write out a fault code to the log stating an M-Code clamp fault. Is there a way to do this?

Thanks,

Scott
Group: DynoMotion Message: 10472 From: Tom Kerekes Date: 11/4/2014
Subject: Re: M-Code Hold Bit
Hi Scott,

You can use the same Thread for different MCode Programs as long as they will never run at the same time.  Think of a Thread as a "Person" that can only follow one set of instructions at a time.

I've attached a C program to wait for a bit for a period of time and after the period of time ask the Operator if they wish to continue waiting, if no then it Halts the GCode.

You must assign this to an Mcode and set the Option Exec/wait/Sync.

You can add a SetBit command before the wait loop if you wish.

HTH
Regards
TK